<?php
require('src/Proveedor.class.php');

$id = (isset($_GET['id'])) ? $_GET['id']:0;
$tpoPer = 0;
$ci_rif = "";
$razonS = "";
$tlfOfi = "";
$tlfMov = "";
$tlfAdi = "";
$emailC = "";
$direcF = "";
$sitioW = "";
if($id!=0){    
    $obj    = new Proveedor();
    $res    = $obj->getConsulta($id);
    if( $row = mysql_fetch_array( $res ) ){
        $tpoPer = $row["PRO_TIPOPERSONA"];
	$ci_rif = $row["PRO_CIRIF"];
        $razonS = $row["PRO_RAZONSOCIAL"];
        $tlfOfi = $row["PRO_TLFOFICINA"];
        $tlfMov = $row["PRO_TLFMOVIL"];
        $tlfAdi = $row["PRO_TLFADICIONAL"];
	$emailC = $row["PRO_EMAIL"];
	$direcF = $row["PRO_DIRECCION"];
        $sitioW = $row["PRO_SITIOWEB"];
    }
}
?>
<script type="text/javascript">
$(document).ready(function() {
    $('#add').click(function() {
    return !$('#select1 option:selected').remove().appendTo('#select2');
   });
   $('#remove').click(function() {
    return !$('#select2 option:selected').remove().appendTo('#select1');
   });
});

</script>  
<form id="formID" class="z-form " method="post" action="">
    <div class="row">
    <div class="cell">
        <label><span class="required">*</span>Tipo Persona</label>
        <?php
            if($tpoPer==0){ ?>
                <input type="radio" id="tpoPer" name="tpoPer" value="1" class="validate[required] radio"> Persona Natural
                <input type="radio" id="tpoPer" name="tpoPer" value="2" class="validate[required] radio"> Persona Jur&iacute;dica
        <?php
            }else if($tpoPer==1){ ?>
                <input type="radio" id="tpoPer" name="tpoPer" value="1" checked="checked"> Persona Natural
                <input type="radio" id="tpoPer" name="tpoPer" value="2" > Persona Jur&iacute;dica
        <?php
            }else if($tpoPer==2){ ?>
                <input type="radio" id="tpoPer" name="tpoPer" value="1" > Persona Natural
                <input type="radio" id="tpoPer" name="tpoPer" value="2" checked="checked" > Persona Jur&iacute;dica
        <?php
            }
        ?>
        </div>
    </div>
    <div class="clear"></div>
    <div class="row">
        <div class="cell">
            <label><span class="required">*</span>CI/RIF</label>
            <input name="ci_rif" class="validate[ minSize[3],maxSize[20]] text-input" type="text" id="ci_rif" value="<?php echo $ci_rif; ?>" />
        </div>
        <div class="cell">
            <label><span class="required">*</span>Nombre/Raz&oacute;n Social</label>
            <input name="razonS" class="validate[ minSize[3],maxSize[150] text-input meddium" type="text"  id="razonS" value="<?php echo $razonS ; ?>"/>
        </div> 
    </div>
	<div class="clear"></div>
    <div class="row">
        <div class="cell">
            <label><span class="required">*</span>Telf. Oficina</label>
            <input name="tlfOfi" class="validate[ minSize[11],maxSize[11], custom[integer]] text-input" type="text" id="tlfOfi" value="<?php echo $tlfOfi; ?>" />
        </div>
        <div class="cell">
            <label><span class="required">*</span>Telf. Movil</label>
            <input name="tlfMov" class="validate[minSize[11],maxSize[11], custom[integer]] text-input " type="text"  id="tlfMov" value="<?php echo $tlfMov; ?>"/>
        </div> 
        <div class="cell">
            <label>Telf. Adicional</label>
            <input name="tlfAdi" class="validate[minSize[11],maxSize[11], custom[integer]] text-input " type="text"  id="tlfAdi" value="<?php echo $tlfAdi; ?>"/>
        </div> 
	</div>
	<div class="row">
        <div class="cell">
            <label><span class="required">*</span>Correo Electr&oacute;nico</label>
			<input name="emailC" class="validate[minSize[3],maxSize[45]] text-input meddium" type="text"  id="emailC" value="<?php echo $emailC ; ?>"/>			
		</div>
		<div class="cell">
			<label>Sitio Web</label>
			<input name="sitioW" class="validate[minSize[3],maxSize[45]] text-input " type="text"  id="sitioW" value="<?php echo $emailC ; ?>"/>
		</div>
    </div>
	<div class="clear"></div>
	<div class="row">
        <div class="cell">
            <label><span class="required">*</span>Direcci&oacute;n</label>
            <textarea rows="2" cols="20" class="full" name="direcF" id="direcF" class="validate[ minSize[3],maxSize[10], custom[integer]] text-input"><?php echo $direcF; ?></textarea>
        </div>
    </div>    
	<div class="clear"></div>
	<div class="row">    
            <div class="cell multiseleccion" >Productos:</br>
                <select multiple id="select1" style="width:200px;">  
                    <?php 
                        $obj    = new Proveedor();
                        $res    = $obj->getOutProveedorMateriaP($id);
                        while($row = mysql_fetch_array($res)){?>
                            <option value="<?=$row["map_id"]?>"> <?=$row["map_nombre"]?></option> 
                    <?php
                        }?>

                </select>  
                <a href="#" id="add">Agregar &gt;&gt;</a>  
            </div>  
            <div class="cell multiseleccion">Insumos que Provee:</br>
                <select multiple id="select2" style="width:200px;">
                    <?php 
                        $obj    = new Proveedor();
                        $res    = $obj->getInProveedorMateriaP($id);
                        while($row = mysql_fetch_array($res)){?>
                            <option value="<?=$row["map_id"]?>"> <?=$row["map_nombre"]?></option> 
                    <?php
                        }?>
                </select>  
                <a href="#" id="remove">&lt;&lt; Eliminar</a>
            </div>
	</div>
</div>	
</form>

